<!DOCTYPE html>
<html>
<head>

	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="description" content="">
	<meta name="author" content="">
	<meta http-equiv="expires" content="0" />
	<meta http-equiv="pragma" content="no-cache" />

	<title>SB Admin - Bootstrap Admin Template</title>

	<!-- Bootstrap Core CSS -->
	<link href="__PUBLIC__/home/css/bootstrap.min.css" rel="stylesheet">
	<link href="__PUBLIC__/home/css/alert.css" rel="stylesheet">


	<!-- Custom Fonts -->
	<!--<link href="_PUBLIC__/font/css/font-awesome.min.css" rel="stylesheet" type="text/css">-->

	<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
	<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
	<!--[if lt IE 9]>
	<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
	<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
	<![endif]-->

</head>
<body>
<!--<div class="container-fluid">-->
<!-- Page Heading -->

<div class="row">
	<ul class="nav nav-tabs" role="tablist">
		<a href="{:U('store/index')}" class="btn btn-primary" role="button">店铺列表</a>
		<button  class="btn btn-default">编辑店铺</button>
	</ul>
	<div class="tab-content col-xs-12">
		<div role="tabpanel" class="tab-pane active" id="message">
			<div class="row">
				<div class="col-sm-10">
					<form id="zyn-form-add" class="form-horizontal" action="{:U('Store/revise')}" method="post" enctype="multipart/form-data">
						<input name="store_id" value="{$store.store_id}" style="display: none;">
						<div class="form-group">
							<label for="lc-input-user_name" class="control-label col-sm-2">用户名</label>
							<div class="col-sm-3">
								<input id="lc-input-user_name" class="form-control" type="text" name="user_name" value="{$store.user_name}"/>
							</div>
							<div class="col-sm-3">
								<p class="lc-p-validate-result p-no-margin" attr-validate = "device_name">*商家登陆账号</p>
							</div>
						</div>
						<div class="form-group">
							<label for="lc-input-phone_mob" class="control-label col-sm-2">手机号</label>
							<div class="col-sm-3">
								<input id="lc-input-phone_mob" class="form-control" type="text" name="phone_mob" value="{$store.phone_mob}"/>
							</div>
							<div class="col-sm-3">
								<p class="lc-p-validate-result p-no-margin" attr-validate = "phone_mob">*手机号</p>
							</div>
						</div>
						<div class="form-group">
							<label for="lc-input-email" class="control-label col-sm-2">邮箱</label>
							<div class="col-sm-3">
								<input id="lc-input-email" class="form-control" type="text" name="email" value="{$store.email}"/>
							</div>
							<div class="col-sm-3">
								<p class="lc-p-validate-result p-no-margin" attr-validate = "email">*邮箱</p>
							</div>
						</div>
						<div class="form-group">
							<label for="lc-input-store_name" class="control-label col-sm-2">店家名称</label>
							<div class="col-sm-3">
								<input id="lc-input-store_name" class="form-control" type="text" name="store_name" value="{$store.store_name}"/>
							</div>
							<div class="col-sm-3">
								<p class="lc-p-validate-result p-no-margin" attr-validate = "store_name">*请填写店铺名</p>
							</div>
						</div>
						<div class="form-group">
							<label for="lc-input-store_name" class="control-label col-sm-2">最低分佣比例</label>
							<div class="col-sm-3">
								<input id="lc-input-min_sub" class="form-control" <if condition="$store['store_type'] eq 'personal'">readonly</if> type="text" name="min_sub" value="{$store.min_sub_value}"/>
							</div>
							<div class="col-sm-3">
								<p class="lc-p-validate-result p-no-margin" attr-validate = "sub">*注：请输入小数！</p>
							</div>
						</div>
						<div class="form-group">
							<label for="lc-input-store_name" class="control-label col-sm-2">销售总金额比较值</label>
							<div class="col-sm-3">
								<input id="lc-input-sub_money" class="form-control" <if condition="$store['store_type'] eq 'personal'">readonly</if> type="number" name="sub_money" value="{$store.sub_money}"/>
							</div>
							<div class="col-sm-3">
								<p class="lc-p-validate-result p-no-margin" attr-validate = "sub_money">*单位：元 注：超过比较值金额 系统自动匹配最高分佣比例！</p>
							</div>
						</div>
						<div class="form-group">
							<label for="lc-input-store_name" class="control-label col-sm-2">最高分佣比例</label>
							<div class="col-sm-3">
								<input id="lc-input-max_sub" class="form-control" <if condition="$store['store_type'] eq 'personal'">readonly</if> type="text" name="max_sub" value="{$store.max_sub_value}"/>
							</div>
							<div class="col-sm-3">
								<p class="lc-p-validate-result p-no-margin" attr-validate = "sub">*注：请输入小数！</p>
							</div>
						</div>

						<if condition="$store['parent_id'] eq 0 && $store['store_type'] eq 'shops'">
							<div class="form-group">
								<label class="control-label col-sm-2">选择结算方式</label>
								<div class="col-sm-3">
									<label>
										<input type="radio" name="settlement_method" value="clique" <if condition="$store.settlement_method eq 'clique'">checked</if>>集团结算
									</label>
									<label>
										<input type="radio" name="settlement_method" value="shop" <if condition="$store.settlement_method eq 'shop'">checked</if>>店铺结算
									</label>
								</div>
							</div>
						</if>

						<div class="form-group">
							<label class="control-label col-sm-2">是否按照地区选择用户</label>
							<div class="col-sm-3">
								<label>
									<input type="radio" name="is_region_choice" value="1" <if condition="$store.is_region_choice eq 1">checked</if>>是
								</label>
								<label>
									<input type="radio" name="is_region_choice" value="2" <if condition="$store.is_region_choice eq 2">checked</if>>否
								</label>
							</div>
							<div class="col-sm-3">
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-sm-2">是否为总店铺</label>
							<div class="col-sm-3">
								<label>
									<input type="radio" name="is_main" value="1" <if condition="$store.parent_id eq 0">checked</if>>是
								</label>
								<label>
									<input type="radio" name="is_main" value="0" <if condition="$store.parent_id neq 0">checked</if>>否
								</label>
							</div>
							<div class="col-sm-3">
							</div>
						</div>
						<div class="form-group" <if condition="$store.is_main eq 1">style="display: none"</if> id="parent">
						<label class="control-label col-sm-2">选择总店铺</label>
						<div class="col-sm-3">
							<select class="p-no-margin form-control" name="parent_id" style="width: auto;">
								<option value="0">请选择店铺</option>
								<volist name="storeList" id="re">
									<option value="{$re.store_id}" <if condition="$re['store_id'] eq $store['parent_id']">selected</if>>{$re.store_name}</option>
								</volist>
							</select>
						</div>
						<div class="col-sm-3">
						</div>
				</div>
				<div class="form-group " id="lc-div-input">
					<label for="lc-input-region_name" class="control-label col-sm-2">地区</label>
					<div class="col-sm-3 form-inline">
						<input id="lc-input-region_name1" class="form-control" type="text" name="region_name1" value="{$store.region_name}" style="width: auto" disabled="ture"/>
						<input id="lc-input-region_name" class="form-control" type="text" name="region_name" value="{$store.region_name}" style="width: auto; display:none"/>

						<button class="btn btn-primary revise-region" type="button">选择地区</button>
					</div>
					<div class="col-sm-3">
						<p class="lc-p-validate-result p-no-margin" attr-validate = "device_name">*地区</p>
					</div>
				</div>
				<div class="form-group" id="lc-div-select" style="display: none">
					<label for="lc-select1-region" class="control-label col-sm-2">地区</label>
					<div class="col-sm-3 form-inline" >
						<select class="p-no-margin form-control" name="region1" value="{$store.region_id}" id="lc-select1-region" style="width: auto;">
							<option value="{$store.region_id}">请选择</option>
							<volist name="region1" id="re">
								<option value="{$re.region_id}">{$re.region_name}</option>
							</volist>
						</select>
						<select class="p-no-margin form-control" value="{$store.region_id}" name="region2" id="lc-select2-region" style="display: none; width: auto;">
							<option value="{$store.region_id}">请选择</option>
						</select>
						<!--<select class="p-no-margin form-control" value="0" id="lc-select3-region" name="region_id" style="display: none; width: auto;">-->
						<!--<option value="0">请选择</option>-->
						<!--</select>-->
					</div>
					<div class="col-sm-3">
						<p class="lc-p-validate-command p-no-margin" attr-validate = "lc-select1-region">*选择地区</p>
					</div>
				</div>
				<div class="form-group">
					<label for="lc-input-store_logo" class="control-label col-sm-2">上传logo</label>
					<div class="col-sm-3">
						<input id="lc-input-store_logo" class="" type="file" name="store_logo" value="{$store.store_logo}"/>
					</div>
					<div class="col-sm-3">
						<img src="../{$store.store_logo}" height="40px;">
						<p class="lc-p-validate-result p-no-margin" attr-validate = "store_logo">*商城logo(不传不做修改)</p>
					</div>
				</div>
				<div class="form-group">
					<label for="lc-input-logo_name" class="control-label col-sm-2">小程序抬头名称</label>
					<div class="col-sm-3">
						<input id="lc-input-logo_name" class="form-control" type="text" name="logo_name" value="{$store.logo_name}"/>
					</div>
					<div class="col-sm-3">
						<p class="lc-p-validate-result p-no-margin" attr-validate = "device_name">*小程序抬头名称</p>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label col-sm-2">宣传二维码</label>
					<div class="col-sm-3">
						<img src="{$store.qr_code}" width="180px;" >
					</div>
				</div>
				<div class="form-group">
					<label for="lc-input-address" class="control-label col-sm-2">地址</label>
					<div class="col-sm-3">
						<input id="lc-input-address" class="form-control" type="text" name="address" value="{$store.address}"/>
					</div>
					<div class="col-sm-3">
						<p class="lc-p-validate-result p-no-margin" attr-validate = "address">*详细地址</p>
					</div>
				</div>
				<div class="form-group">
					<label for="lc-select-state" class="control-label col-sm-2">状态</label>
					<div class="col-sm-3">
						<select class="p-no-margin form-control" value="0" id="lc-select-state" name="state">
							<option value="0" <if condition="$store.state eq 0">selected</if>>未选择</option>
							<option value="1" <if condition="$store.state eq 1">selected</if>>启用</option>
							<option value="2" <if condition="$store.state eq 2">selected</if>>关闭</option>
						</select>
					</div>
					<div class="col-sm-3">
						<p class="lc-p-validate-command p-no-margin" attr-validate = "lc-select-state">*是否启用该店铺</p>
					</div>
				</div>
				<div class="col-xs-10 col-xs-offset-2">
					<button class="btn btn-primary btn-submit" id="lc-btn-save" type="submit">提交保存</button>
					<a href="javascript:history.back(-1)" class="btn btn-primary" id="lc-btn-return">返回上一页</a>
				</div>
				</form>
			</div>
		</div>
	</div>
</div>
</div>

<include file = "Public/html/footer.html" />

<script src=""></script>
<script>

    $("input[name=is_main]").change(function(){
        var is_show_gift = $('input[name=is_main]:checked').val();
        if(is_show_gift == 0){
            $("#parent").show();
        }else{
            $("#parent").hide();
        }
    })


    var region = '';
    $("#lc-select1-region").on('change',function () {
        if($(this).val()){
            $.ajax({
                type:"post",
                url:"{:U('Store/getRegion')}",
                async:true,
                data:{'parent_id':$(this).val()},
                dataType:"json",
                success:function(result) {
                    if (result.code == 10000) {
                        var shtml = '';
                        for(var i in result.data){
                            shtml += '<option value="'+result.data[i].region_id+'">'+result.data[i].region_name+'</option>'
                        }
                        var start = '<option value="0" selected>请选择</option>'
                        $("#lc-select2-region").html(start+shtml)
                        $("#lc-select2-region").css('display','');
                        $("#lc-select3-region").css('display','none');
                        change_region();
                    }
                }
            });
        }
    })
    $("#lc-select2-region").on('change',function () {
        if($(this).val()){
            $.ajax({
                type:"post",
                url:"{:U('Store/getRegion')}",
                async:true,
                data:{'parent_id':$(this).val()},
                dataType:"json",
                success:function(result) {
                    if (result.code == 10000) {
                        var shtml = '';
                        for(var i in result.data){
                            shtml += '<option value="'+result.data[i].region_id+'">'+result.data[i].region_name+'</option>'
                        }
                        var start = '<option value="0" selected>请选择</option>'
                        $("#lc-select3-region").html(start+shtml)
                        $("#lc-select3-region").css('display','');
                        change_region();
                    }
                }
            });
        }
    })
    $("#lc-select3-region").on('change',function () {
        change_region();
    });
    function change_region() {
        region = ''
        console.log($("#lc-select3-region").val())
        if($("#lc-select1-region").val() != 0){
            region += $("#lc-select1-region option:selected").text() + ' ';
        }
        if($("#lc-select2-region").val() != 0){
            region += $("#lc-select2-region option:selected").text() + ' ';
        }
        if($("#lc-select3-region").val() != 0){
            region += $("#lc-select3-region option:selected").text() + ' ';
        }
        $("#lc-input-region_name").val(region);
        console.log($("#lc-input-region_name").val())
    }
    $("#lc-btn-return").click(function () {
        location.href = "{:U('Store/index')}";
    })
    $("button.revise-region").click(function () {
        $("#lc-div-input").css('display','none');
        $("#lc-div-select").css('display','');
        $("#lc-input-region_name").removeAttr('disabled');
    })
</script>
</body>

</html>
